package com.pearadmin.modules.sys.controller;

import com.pearadmin.common.constant.ControllerConstant;
import com.pearadmin.common.web.base.BaseController;
import com.pearadmin.common.web.domain.response.Result;
import com.pearadmin.modules.sys.domain.SysCustomer;
import com.pearadmin.modules.sys.dto.CustomerSubmitDTO;
import com.pearadmin.modules.sys.service.CustomerService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = {"客户信息控制"})
@RequestMapping(ControllerConstant.API_SYSTEM_PREFIX + "customer")
public class SysCustomerController extends BaseController {

    CustomerService customerService;


    @PostMapping("submitAndEmail")
    public Result submitAndEmail(CustomerSubmitDTO dto){
        customerService.submitAndEmail(dto);
        return Result.success();
    }

    @GetMapping("save")
    public Result save(){
        SysCustomer sysCustomer = new SysCustomer();
        sysCustomer.setId("1001");
        sysCustomer.setCompanyName("三谷泰机");
        sysCustomer.setCustomerName("铠甲勇士");
        sysCustomer.setCustomerPhone("12345678910");
        Integer i = customerService.save(sysCustomer);
        if (i>0){
            return Result.success();
        }else {
            return Result.failure();
        }

    }

    @GetMapping("findAll")
    public Result findAll(){
        return Result.success(customerService.findAll());
    }


}
